package com.gitee.ywj1352.customer.rest;

import com.gitee.ywj1352.common.constants.CommonConstants;
import com.gitee.ywj1352.common.pojo.User;
import com.gitee.ywj1352.common.vo.ResponseVO;
import com.gitee.ywj1352.customer.biz.UserBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by wenjie.yang on 6/26/2018.
 */
@RestController
@RequestMapping("/cm")
public class CustomerController {

    @Autowired
    private UserBiz userBiz;

    @GetMapping("{id}")
    public ResponseVO getUserId(@PathVariable("id") Long id){
        User user = userBiz.selectById(id);
        return new ResponseVO(user);
    }


    @PostMapping
    public ResponseVO login(User user){

        if (user.getPassword()=="123" && user.getUserName()=="ywj"){
            User user1 = new User();
            user1.setNikeName("ywj");
            user1.setAge(11);
            user1.setPassword("123");
            return new ResponseVO(user1);
        }
        return new ResponseVO(CommonConstants.EX_OTHER_CODE);
    }

}
